home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / cp2dekit / samples / binfile.cpp < prev    next >
C/C++ Source or Header  |  1996-12-29  |  2KB  |  159 lines

  1. //***************************************************************************
  2. //
  3. // this file is (c) '94-'96 Niklas Beisert
  4. //
  5. // this file is part of the cubic player development kit.
  6. // you may only use/modify/spread this file under the terms stated
  7. // in the cubic player development kit accompanying documentation.
  8. //
  9. //***************************************************************************
  10.  
  11.  
  12. #include "binfile.h"
  13.  
  14. binfile::binfile()
  15. {
  16.   binfile::close();
  17. }
  18.  
  19. binfile::~binfile()
  20. {
  21.   close();
  22. }
  23.  
  24. void binfile::close()
  25. {
  26.   filepos=filelen=0;
  27.   mode=0;
  28. }
  29.  
  30. long binfile::read(void *, long)
  31. {
  32.   return 0;
  33. }
  34.  
  35. long binfile::write(const void *, long)
  36. {
  37.   return 0;
  38. }
  39.  
  40. long binfile::seek(long)
  41. {
  42.   return filepos;
  43. }
  44.  
  45. long binfile::chsize(long)
  46. {
  47.   return filelen;
  48. }
  49.  
  50. long binfile::tell()
  51. {
  52.   return filepos;
  53. }
  54.  
  55. long binfile::length()
  56. {
  57.   return filelen;
  58. }
  59.  
  60. int binfile::eof()
  61. {
  62.   return filepos==filelen;
  63. }
  64.  
  65. long binfile::seekcur(long pos)
  66. {
  67.   return seek(filepos+pos);
  68. }
  69.  
  70. long binfile::seekend(long pos)
  71. {
  72.   return seek(filelen+pos);
  73. }
  74.  
  75. int binfile::eread(void *buf, long len)
  76. {
  77.   return read(buf,len)==len;
  78. }
  79.  
  80. int binfile::ewrite(const void *buf, long len)
  81. {
  82.   return write(buf,len)==len;
  83. }
  84.  
  85. char binfile::getc()
  86. {
  87.   char c=0;
  88.   read(&c, 1);
  89.   return c;
  90. }
  91.  
  92. short binfile::gets()
  93. {
  94.   short s=0;
  95.   read(&s, 2);
  96.   return s;
  97. }
  98.  
  99. long binfile::getl()
  100. {
  101.   long l=0;
  102.   read(&l, 4);
  103.   return l;
  104. }
  105.  
  106. binfile &binfile::putc(char c)
  107. {
  108.   write(&c, 1);
  109.   return *this;
  110. }
  111.  
  112. binfile &binfile::puts(short s)
  113. {
  114.   write(&s, 2);
  115.   return *this;
  116. }
  117.  
  118. binfile &binfile::putl(long l)
  119. {
  120.   write(&l, 4);
  121.   return *this;
  122. }
  123.  
  124. char binfile::egetc(int &stat)
  125. {
  126.   char c=0;
  127.   stat=eread(&c, 1);
  128.   return c;
  129. }
  130.  
  131. short binfile::egets(int &stat)
  132. {
  133.   short s=0;
  134.   stat=eread(&s, 2);
  135.   return s;
  136. }
  137.  
  138. long binfile::egetl(int &stat)
  139. {
  140.   long l=0;
  141.   stat=eread(&l, 4);
  142.   return l;
  143. }
  144.  
  145. int binfile::eputc(char c)
  146. {
  147.   return ewrite(&c, 1);
  148. }
  149.  
  150. int binfile::eputs(short s)
  151. {
  152.   return ewrite(&s, 2);
  153. }
  154.  
  155. int binfile::eputl(long l)
  156. {
  157.   return ewrite(&l, 4);
  158. }
  159.